import { useModel } from '@umijs/max';
import { useState } from 'react';
export const useGetPreviewImgs = (
    data?: string[],
  ): [string[], (data?: string) => void] => { 
    const { initialState } = useModel('@@initialState');
    const [PreviewImgs, onHandlePreviewImgs] = useState<string[]>(data ?? []);
    const setPreviewImgs = (data: string | undefined) => {
      onHandlePreviewImgs(
        data
          ?.split(',')
          .filter((item) => Boolean(item))
          .map((item) => initialState?.PreviewUrl + item) ?? [],
      );
    };
    return [PreviewImgs, setPreviewImgs];
  };
  